package com.test.convert;

import java.util.Map;

import org.apache.struts2.util.StrutsTypeConverter;

import com.test.bean.Point;

public class PointConvert1 extends StrutsTypeConverter
{

	@Override
	public Object convertFromString(Map arg0, String[] arg1, Class arg2)
	{
		System.out.println("convertFromString ...");
		
		String value = arg1[0];
		
		String[] values = value.split(",");
		
		Integer x = Integer.parseInt(values[0]);
		Integer y = Integer.parseInt(values[1]);
		
		Point point = new Point();
		point.setX(x);
		point.setY(y);
		
		
		return point;
	}

	@Override
	public String convertToString(Map arg0, Object arg1)
	{
		System.out.println("convertToString ...");
		
		Point point = (Point)arg1;
		
		String result = "Convert1, X:" + point.getX() + " | Y:" + point.getY();
		return result;
		
	}
}
